package com.ruoyi.deeplearn.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.deeplearn.domain.DeepDatasetMark;
import com.ruoyi.deeplearn.service.IDeepDatasetMarkService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 标记Controller
 *
 * @author rww
 * @date 2022-12-11
 */
@RestController
@RequestMapping("/deeplearn/mark")
public class DeepDatasetMarkController extends BaseController
{
    @Autowired
    private IDeepDatasetMarkService deepDatasetMarkService;

    /**
     * 查询标记列表
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:mark:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeepDatasetMark deepDatasetMark)
    {
        startPage();
        List<DeepDatasetMark> list = deepDatasetMarkService.selectDeepDatasetMarkList(deepDatasetMark);
        return getDataTable(list);
    }

    /**
     * 导出标记列表
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:mark:export')")
    @Log(title = "标记", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeepDatasetMark deepDatasetMark)
    {
        List<DeepDatasetMark> list = deepDatasetMarkService.selectDeepDatasetMarkList(deepDatasetMark);
        ExcelUtil<DeepDatasetMark> util = new ExcelUtil<DeepDatasetMark>(DeepDatasetMark.class);
        util.exportExcel(response, list, "标记数据");
    }

    /**
     * 获取标记详细信息
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:mark:query')")
    @GetMapping(value = "/{markId}")
    public AjaxResult getInfo(@PathVariable("markId") Long markId)
    {
        return success(deepDatasetMarkService.selectDeepDatasetMarkByMarkId(markId));
    }

    /**
     * 新增标记
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:mark:add')")
    @Log(title = "标记", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeepDatasetMark deepDatasetMark)
    {
        return toAjax(deepDatasetMarkService.insertDeepDatasetMark(deepDatasetMark));
    }

    /**
     * 修改标记
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:mark:edit')")
    @Log(title = "标记", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeepDatasetMark deepDatasetMark)
    {
        return toAjax(deepDatasetMarkService.updateDeepDatasetMark(deepDatasetMark));
    }

    /**
     * 删除标记
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:mark:remove')")
    @Log(title = "标记", businessType = BusinessType.DELETE)
	@DeleteMapping("/{markIds}")
    public AjaxResult remove(@PathVariable Long[] markIds)
    {
        return toAjax(deepDatasetMarkService.deleteDeepDatasetMarkByMarkIds(markIds));
    }
}
